#include<iostream>
#include<vector>

using namespace std;
vector<int> get_next(string sub)
{
	vector<int>next(sub.size());
	next[0] = -1;
	int j=1, k=-1;
	while (j<sub.size())
	{
		if (k == -1 || sub[j - 1] == sub[k])
			next[j++] = ++k;
		else
			k = next[k];
	}
	return next;

}
int KMP (string S, string sub,vector<int>next)
{
	int i = 0;
	int j = 0;
	while (i < S.size()&& (j==-1||j < sub.size()))
	{
		if (j == -1 || S.at(i) == sub.at(j))
		{
			++i; ++j;
		}
		else
			j = next[j];
	if (j >=sub.size())return i - j;
	else return -1;
}
int main(void){
	cout << "请输入主串，t1字串以及t2字串，主串中的t1字串将被全部替换为t2字串" << endl;
	int n;
	string S, t1, t2;
	cin >> S >> t1 >> t2;
	vector<int>next(t1.size());
	next = get_next(t1);
	while (true)
	{
		if ((n = KMP(S, t1, next)) != -1)
		{
			S.replace(n, t1.size(), t2);
			cout << S << endl;
		}
		else break;
	}
	cout << S << endl;
	return 0;
}